import permissionApi from "@/api/declaration/permissionApi"
import httpRequest from "@/config/axios/httpRequest"
import { 
  PermissionAssignRoleDataScopeModel, 
  PermissionAssignUserRoleModel 
} 
from "@/models/permission/PermissionAssignUserRoleModel"


// 查询角色拥有的菜单权限
export const getRoleMenuList = async (roleId: number) => {
  return await httpRequest.get(permissionApi.GetRoleMenuList, { params: { roleId } })
}

// 赋予角色菜单权限
export const assignRoleMenu = async (data: PermissionAssignUserRoleModel) => {
  return await httpRequest.post(permissionApi.AssignRoleMenu, data)
}

// 赋予角色数据权限
export const assignRoleDataScope = async (data: PermissionAssignRoleDataScopeModel) => {
  return await httpRequest.post(permissionApi.AssignRoleDataScope, data)
}

// 查询用户拥有的角色数组
export const getUserRoleList = async (userId: number) => {
  return await httpRequest.get(permissionApi.GetUserRoleList, { params: { userId } })
}

// 赋予用户角色
export const assignUserRole = async (data: PermissionAssignUserRoleModel) => {
  return await httpRequest.post(permissionApi.AssignUserRole, data)
}
